Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of the error that occurred:
While fixing the fnlp-core module of this project earlier, I noticed that the fnlp-demo module of the project reported an error when running a test of the whole project, i.e. using the code
mvn test
.The error message is:
After look through the error logs, I found out that there are 3 tests where the error occurs, they are:
All three tests would cause one same failure, this is:
And for the
SimpleClassifier2.java
, it not only have the above problem, it also has another failure:Reasons for the error and how to fix
First for the failure that all three tests all exist, it is because they used
System.exit(0);
at the end of the file.Using
System.exit()
in a Java program immediately terminates the currently running Java Virtual Machine (JVM). This method is typically used in application-specific scenarios, such as situations where program execution needs to be stopped immediately. This leads toThe forked VM terminated without saying properly goodbye
. When we removedSystem.exit(0);
from all three files, this problem was resolved immediately.And next for the
NullPointerException
failure in theSimpleClassifier2.java
file, the key goes to theSimpleFileReader.hasNext
function. The original code didn't check if the reader is null or not, so it would cause aNullPointerException
if a reader is null. We just need to check if a reader is null at first to solve this problem.How to reproduce the problem
Simply run 'mvn test', and there will be a failure occur.